﻿#region Using Directives

    using System;
    using System.Linq;

    using Csla;

    using MarketPulse.BusinessLogic.Core;
    using MarketPulse.Reporting.Core.Criteria;

#endregion

namespace MarketPulse.Reporting.Core
{
    /// <summary>
    /// This class represents a collection of Reporting Visits
    /// </summary>
    [Serializable]
    [Csla.Server.ObjectFactory("MarketPulse.DataAccess.Factory.ReportingVisitFactory, MarketPulse.DataAccess.Factory", "FetchInfoList")]
    public class ReportingVisitInfoList : MarketPulseReadOnlyListBase<ReportingVisitInfoList, ReportingVisitInfo>
    {

        #region Constructors

            /// <summary>
            /// Default constructor is private in order to (try to) enforce construction
            /// only via the static factory methods provided.
            /// </summary>
            private ReportingVisitInfoList()
            {
            }

        #endregion

        #region Methods

            #region Factory Methods

                ///// <summary>
                ///// Method used to get a read only list of read only ReportingVisits that are associated with a ReportingPeriod (via the DataPortal client proxy)
                ///// </summary>
                ///// <param name="clientGUID">The GUID of the Client used to retrieve the list</param>
                ///// <param name="profileGUID">The GUID of the Profile used to retrieve the list</param>
                ///// <param name="reportingPeriod">The ReportingPeriod used to retrieve the list</param>
                ///// <returns>A populated read only list of read only ReportingVisits</returns>
                //public static ReportingVisitInfoList GetByClientGUIDAndProfileGUIDAndDateRange(ResultsCriteria criteria)
                //{
                //    return DataPortal.Fetch<ReportingVisitInfoList>(criteria);
                //}

                ///// <summary>
                ///// Method used to get a read only list of read only ReportingVisits that are associated with a ReportingPeriod (via the DataPortal client proxy)
                ///// </summary>
                ///// <param name="clientGUID">The GUID of the Client used to retrieve the list</param>
                ///// <param name="reportingPeriod">The ReportingPeriod used to retrieve the list</param>
                ///// <returns>A populated read only list of read only ReportingVisits</returns>
                //public static ReportingVisitInfoList GetByClientGUIDReportingPeriod(ResultsCriteria criteria)
                //{
                //    return DataPortal.Fetch<ReportingVisitInfoList>(criteria);
                //}

                /// <summary>
                /// Method used to get a read only list of read only ReportingVisits that are associated with a ReportingPeriod (via the DataPortal client proxy)
                /// </summary>
                /// <param name="criteria">The results criteria object containing values to retrieve results for.</param>
                /// <returns>A populated read only list of read only ReportingVisits</returns>
                public static ReportingVisitInfoList GetByClientGUIDAndReportingLevelAndDateRange(ResultsCriteria criteria)
                {
                    return DataPortal.Fetch<ReportingVisitInfoList>(criteria);
                }

                ///// <summary>
                ///// Method used to get a read only list of read only ReportingVisits that are associated with a Branch (previous Visits based on Branch and Date and time to go back to) (via the DataPortal client proxy)
                ///// </summary>
                ///// <param name="clientGUID">The criteria object to use to retrieve the list</param>
                ///// <returns>A populated read only list of read only ReportingVisits</returns>
                //public static ReportingVisitInfoList GetByClientGUIDAndDateRange(ResultsCriteria criteria)
                //{
                //    return DataPortal.Fetch<ReportingVisitInfoList>(new ClientGUIDAndBranchGUIDAndDateRangeCriteria(criteria.ClientGUID, criteria.BranchGUID.Value, criteria.Language, criteria.DataStartDateTime, criteria.DataEndDateTime));
                //}

            #endregion

            /// <summary>
            /// Method used to find a single ReportingVisitsInfo object from the collection based on the visitGuid supplied
            /// </summary>
            /// <param name="visitGuid">The guid that uniquely identifies the Reporting Visit Info object to find</param>
            /// <returns>A populated Reporting Visit Info object</returns>
            public ReportingVisitInfo FindByGuid(Guid visitGuid)
            {
                var result = (from visit in this.Items
                              where visit.GUID == visitGuid
                              select visit).First();

                return (ReportingVisitInfo)result;
            }

        #endregion
    }
}
